/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package unidad_3;

import java.awt.Canvas;
import java.awt.*;

/**
 *
 * @author jcverdia
 */


public class Dibujo extends Canvas {

    private int x1;
    private int y1;
    private int x2;
    private int y2;
    private int clicks;


     public void addPunto(int x, int y){
            clicks++;
            if(clicks==1)
            {
                this.x1=x;
                this.y1=y;

            }
            else
            {
              this.x2=x;
              this.y2=y;
              clicks=0;
            }
            repaint();
        }



    public void paint(Graphics g){







        if(clicks==1){
          g.drawOval(x1-10, y1-10, 20, 20);

        }
            else {
           // g.drawLine(x1, y1, x2, y2);

//            g.setColor(Color.RED);
//

        g.drawLine((int)(x1+(x2-x1)/2), y1, x2, (int)(y1+(y2-y1)/2));
        g.drawLine((int)(x1+(x2-x1)/2), y1, x1, (int)(y1+(y2-y1)/2));

        g.drawLine(x1,(int)(y1+(y2-y1)/2), (int)(x1+(x2-x1)/2),y2);
        g.drawLine(x2,(int)(y1+(y2-y1)/2), (int)(x1+(x2-x1)/2),y2);

//int px[]={100,200,200,300};
//int py[]={200,300,300,400};
//
//       g.drawPolyline(px, py, 4);


//        g.drawRoundRect(50, 100, 150,200, 250, 300);
//        g.drawLine(x1, 0, 300, 400);
//        g.drawLine(x1, 0, 300, 400);
//        g.drawRect(100, 200, 200, 300);
//        g.drawOval(20, 40, 100, 100);
//



}






}





}




